![]() ![]() |
Q: I'd like to send a SCSI command to my hard drive or other storage device. The SCSITask User Client seems to be the right API, but it doesn't work when I try to use it with a hard drive. What's going on? A: Apple does not support sending SCSI commands to hard drives from an application. By design, only one logical unit driver at a time can control a device. We provide in-kernel drivers for hard drives and other SCSI Architecture Model (SAM) devices based on the peripheral device type returned from an INQUIRY command. Here's the relevant quote from the book Inside Mac OS X: Accessing Hardware from Applications: "The SCSI Architecture Model family provides in-kernel logical unit drivers that translate generic I/O requests into device-specific commands for devices on these buses that declare one of the following four peripheral device types:
For devices that declare other peripheral device types, such as scanners, tape drives, and medium changers, the SCSI Architecture Model family provides a device interface, called the SCSITaskDeviceInterface, that allows an application to be the logical unit driver for that device." Since hard drives have a peripheral device type of 0x00, we provide an in-kernel driver and no SCSITaskDeviceInterface. The same rationale applies to ATA drives: the ATA family also does not provide a device interface for sending commands from applications. This architecture has two significant advantages. Since applications cannot arbitrarily change the state of a device, the operating system's view of the device is always consistent, thus enhancing stability. Plus, data security is enhanced by limiting the ability to bypass file system permissions. If you're just interested in the information you'd get from
a SCSI INQUIRY or ATA IDENTIFY DEVICE command, much of that
information is published in the I/O Registry. You can use
the application An alternative for doing I/O operations is to use the BSD raw disk device in /dev. This is described in the chapter of "Accessing Hardware from Applications" titled Working with Device Files for Storage Devices. An example of this is the AudioCDSample. [Jul 25 2002] |
Developer Documentation | Technical Notes | Development Kits | Sample Code |